package com.wu.cloud.gateway.component;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;

/**
 * @author xwu36
 */
@Configuration
@Slf4j
public class RouterUrlConfiguration {
    private static final String SEPARATOR = ",";

    @Value("${pesk.custom.token.pass-url}")
    String urlString;

    @Bean
    public List<String> addPassUrlBean() {
        List<String> passUrlList = new LinkedList<>();
        if (urlString.contains(SEPARATOR)) {
            String[] strings = urlString.split(SEPARATOR);
            passUrlList.addAll(Arrays.asList(strings));
        } else {
            passUrlList.add(urlString);
        }
        if (log.isDebugEnabled()) {
            log.debug("无需Token的路径:" + passUrlList.toString());
        }
        return passUrlList;
    }
}
